<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改人员信息</title>
    <link rel="stylesheet" href="<%=basePath%>web/css/from.css">
    <link rel="stylesheet" href="<%=basePath%>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath%>web/themes/icon.css">
    <script src="<%=basePath%>web/js/jquery.min.js"></script>
    <script src="<%=basePath%>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath%>web/js/easyui-lang-zh_CN.js"></script>
    <script>
       $(function(){
	     $("#save").click(function(){
		    var userName=$("#userName").textbox("getValue");
		    var roleName=$("#roleName").val();
		    var pwd=$("#pwd").textbox("getValue");
		    var depart=$("#depart").textbox("getValue");
		    var id=$("#id").val();
				$.ajax({
				type:"post",//请求类型
				url:"/kxmanage/administrator/updateAdministrator", 
				data:{"userName":userName,"rol_id":roleName,"pwd":pwd,"depart":depart,"id":id},
				dataType:"json",//ajax接口（请求url）返回的数据类型
				success:function(data){//data：返回数据（json对象）
					if(data.result=="error"){
					    alert("修改失败");
					}
					else if(data.result=="success"){
						alert("修改成功");
						parent.addTabs('管理人员管理','goods/administrator.jsp');
						parent.closeTabs('人员信息');
					}
					else if(data.result=="noPower"){
        				alert("您没有权限！");
        			} 
				}  
				}); 
				}); 
	    
	      $.ajax({
         	type:"GET",//请求类型
		 	url:"/kxmanage/administrator/findalltype",//请求的url
		 	dataType:"json",//ajax接口（请求url）返回的数据类型
		 	success:function(data){//data：返回数据（json对象）
		 		if(data != null){
		 			var roleID=$("#roleID").val();
		 			$("#roleName").html("");
					var options = "";
					for(var i = 0; i < data.length; i++){
					   if(roleName != null && roleName != undefined && data[i].id == roleID){
					    options += "<option selected=\"selected\" value=\""+data[i].id+"\">"+data[i].roleName+"</option>";
					   }else{
						options += "<option value=\""+data[i].id+"\">"+data[i].roleName+"</option>";
					   }
					}
					$("#roleName").html(options);
					}
		 	}
          });
	    
       });
       
         function reload(){
            parent.addTabs("人员信息","/kxmanage/web/goods/addAdministrator.jsp");
         }  
         
         function Close(){
            parent.closeTabs("人员信息");
         }
         
                  
    </script>
    <style>
        body {
            font-size:12px;
            padding:10px
        }
        .l-table-edit {
          border-collapse:collapse;
          border-spacing:0;
        }
        .l-table-edit-td {
            padding:4px;
            font-size:12px;
            border:1px solid #84a0c4 
        }
        
    </style>


</head>
<body>
<form name="form"  id="form" action="" method="post">
    <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width:100%">
        <tr >
            <td width="17%"  align="right" class="l-table-edit-td">用户账号：</td>
            <td width="27%" align="left" class="l-table-edit-td">
            <input  type="text" id="userName" name="userName" value="${user.userName}" maxlength="30" class="easyui-textbox" style="height:20px"/>
            </td>
            <td width="13%"  align="right" class="l-table-edit-td">角色权限：</td>
            <td width="43%" align="left" class="l-table-edit-td">
            <select name="roleName" id="roleName" style="width:120px;height:20px" panelHeight="120px">
            </select>    
            </td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">密码：</td>
            <td width="27%" align="left" class="l-table-edit-td">
            <input  type="text" id="pwd" name="pwd" class="easyui-textbox" value="${user.pwd}"  maxlength="50" ltype="text" style="height:20px"/>
            </td>
            <td width="13%" align="right" class="l-table-edit-td">所在部门：</td>
            <td width="43%" align="left" class="l-table-edit-td">
            <input type="text" id="depart" name="depart" class="easyui-textbox" value="${user.depart}" maxlength="50"  ltype="text" style="height:20px"/>
            </td>
        </tr>
    </table>
</form>
<br>
<input type="hidden" id="id" value="${user.id}"/>
<input type="hidden" id="roleID" value="${user.Rol_id}"/>
<input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
<input  type="button" value="新   增" onclick="reload()" style="width:60px">
<a href="javascript:;"><input id="save" type="button" value="保存" style="width:60px"></a>
<input  type="button" value="打印" style="width:60px">
<input  type="button" onclick="Close()" value="关闭" style="width:60px">
</body>
</html>